package com.cookman.gameobjects.ActionButtons.listeners;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.cookman.gameobjects.ActionButtons.ActionActor;
import com.cookman.serviceLocators.ServiceLocator;


public class ExecuteActionListener extends InputListener {

    @Override
    public boolean touchDown(InputEvent event, float x, float y,
                             int pointer, int button) {
        return true;
    }

    @Override
    public void touchUp(InputEvent event, float x, float y, int pointer,
                        int button) {
        if (event.getTarget() instanceof ActionActor) {
            ActionActor actor = (ActionActor) event.getTarget();
            ServiceLocator.getUIController().executeAction(actor.getAction());
        }
    }

    @Override
    public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
        super.enter(event, x, y, pointer, fromActor);
    }
}

